import re
# conding=utf-8
# X=re.findall('I\\b','hello I am LIST')
# X=re.findall(r'I\b','hello I am LIST')
# X=re.findall('c\\\f','abdc\fhsdahfu')
# X=re.findall('kc|d','abkc|dahfu')
# X=re.findall(r'(abc|def)','abcabcabcabcdefdefdefdefdef')
# X=re.findall(r'(abc)','abccccccabcabcabcdefdefdefdefdef')
# X=re.search('\d(3)','ab34e5ccccccg232')
# X=re.search('\d(3)','ab34e5ccccccg232').group()
# m='alec12523fsdnauh678xadf878'
# X=re.search('(?P<name>[a-z]+)\d+',m).group('name')
# R=re.search('(?P<name>[a-z]+)(?P<age>\d+)',m).group('age')
# print (X)
# print(R)

# H=re.match('\d+','32abdchsdahfu')
# H=re.split(' ','hello I am LIST')
# l=re.split('[  |]','hello I am LIdfsaf|fST')
# p=re.split('[ab]','acdadfadibrge')
# print(H)
# print(l)
# print(p)
# com =re.compile('\d+')
# m=com.subn('A','abccc5cc5cs2ab32c525abc666abcdefdefd6efd3efdef')
# print(m)
'''
X0=re.findall('\d(3)','ab34e5555ccccccg232')
y0=re.finditer('\d(2)','ab34e5555c53cc0258cccg232')
# mm =next(y0)
# print(mm)
MM=next(y0).group()
print(MM)
MM=next(y0).group()
print(MM)


t=re.findall('(abc)+','abbabcabcabcabc')
print(t)  #----> ['abc']
tt=re.findall('(?:abc)+','abbabcabcabcabc')
print(tt) #----> ['abcabcabcabc']
ttt=re.findall('abc+','abbabcabcabcabc')
print(ttt) #----> ['abc','abc','abc',abc']

'''
# s='1    - 2 *((60-30+(-40 /5) * (9-2* 5/3 + 7 /3* 99/4* 2998 +10 * 568/14)) -(-4 *3)/(16 -3*2))'
# x=re.subn(" ","",s)
# # print(x)
# def seaerch():
#     while True:
#         sum = 0
#         m = re.search('\([^()]\)',x) # (16 -3*2)
#         # 16-3*2
#         n = re.split('(\+|-|\*|/)',m)
#         for
#
#
#         l = int(n)
#
#         sum+= l
#
#         re.subn('sum','m',x)
#         print(m)
#         if m=='':
#             break
#
# import re
# kk='16-3*2'
# mm=re.compile('(-|\*)')
# kk0=mm.split(kk)

def add(x,y):
    return x+y
def subtraction(x,y):
    return x-y
def multiplication(x,y):
    return x*y
def division(x,y):
    return x/y


kk0=['16', '-', '3', '/', '2','/','5','3', '*', '2']
def AA():
    sum0 =0
    for k in range(len(kk0)):
        if kk0[k] !='*' and kk0[k]!='/' and kk0[k]!='+' and kk0[k]!='-':
            kk0[k]= int(kk0[k])
            print(kk0[k])
    kk1 = kk0
    if len(kk1)>1:
        target = False
        dt =['/','*']
        while not target:
            for i in range(kk1):
                if kk1[i] in dt:
                    target = True
                    print(kk1[i])
                    if kk1[i] =='*':
                        sum0 = multiplication(kk1[i-1], kk1[i+1])
                        kk1[i-1]=sum0
                        del kk1[i:i+1]
                    else:
                        sum0 = division(kk1[i-1], kk1[i+1])
                        kk1[i - 1] = sum0
                        del kk1[i:i+1]
                    target = False
                elif kk1[i] =='+':
                    sum0 = add(kk1[i-1],kk1[i+1])
                    kk1[i - 1] = sum0
                    del kk1[i:i+1]
                if kk1[i] =='-':
                    sum0 = subtraction(kk1[i-1],kk1[i+1])
                    kk1[i-1] = sum0
                    del kk1[i:i + 1]
    else:
        return kk1[0]
AA()




